<html>
<head>
<title>CSS3 media query test: deleteMedium throwing exception.</title>
<link rel="help" href="http://www.w3.org/TR/css3-mediaqueries/" />

<style type="text/css">
@media all and (color) {
p#result { color: green;}
}
</style>

<script language="javascript">
function test() {
    try {
        document.styleSheets[0].cssRules[0].media.deleteMedium("all and (");
        document.getElementById("result").innerHTML = "Failure. 'all and (' is not a valid media query and should become 'not all'. Not all is not present in the media rule, hence a DOMException.NOT_FOUND_ERR should be thrown."
    }
    catch(e) {
        if (e.code == DOMException.NOT_FOUND_ERR)
            document.getElementById("result").innerHTML = "Success. This text should be green.";
        else {
            document.getElementById("result").innerHTML = "Failure. Wrong exception thrown. Expected DOMException.NOT_FOUND_ERR.";
            document.getElementById("details").innerHTML = "Following exception was caught: " + e;
        }
    }
}
</script>


</head>
<body onload="test()">
<p>The text below should read "Success." </p>
<p id="result">Failure: test not run.</p>
<p id="details"></p>
</body>
</html>
